﻿@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>RolePower</title>
</head>
<body>
    <div id="leftdiv" style="float:left;width:40%;">
        <table id="lefttable">
            <thead>
                <tr>
                    <th>角色名称</th>
                </tr>
            </thead>
            <tbody></tbody>
        </table>
    </div>
    <div id="rightdiv" style="float:right;width:50%">
        <table id="righttable" width="100%">
            <thead>
                <tr>
                    <th width="40%">全选<input type="checkbox" id="rightcheckbox" /></th>
                    <th width="60%">权限名称</th>
                </tr>
            </thead>
            <tbody></tbody>
        </table>
    </div>
</body>
</html>
<script src="~/Scripts/jquery-1.8.2.min.js"></script>
<script>
    $(function () {
        $.ajax({
            url: "/Home/ShowRole",
            type: "get",
            success: function (roledata) {
                $("#lefttable tbody").empty();
                $(roledata).each(function (roleid, rolename) {
                    var lefttbody = "";
                    lefttbody += '<tr>';
                    lefttbody += '<th><a id="' + rolename.RoleID + '">' + rolename.RoleName + '</a></th>';
                    lefttbody += '</tr>';
                    $("#lefttable tbody").append(lefttbody);
                })
            }
        });
        $.ajax({
            url: "/Home/TwoPower",
            type: "get",
            data:{
                ProviceID:0
            },
            success: function (powerdata) {
                $("#righttable tbody").empty();
                $(powerdata).each(function (powerid, powername) {
                    var righttbody = "";
                    righttbody += '<tr>';
                    righttbody += '<th width="40%"><input type="checkbox" name="rightcheck" value="' + powername.PowerID + '" /></th>  ';
                    righttbody += '<th width="60%">' + powername.PowerName + '</th>';
                    righttbody += '</tr>';
                    $("#righttable tbody").append(righttbody);
                    $.ajax({
                        url: "/Home/TwoPower",
                        type: "get",
                        data:{
                            ProviceID:powername.PowerID
                        },
                        success: function (powerdata) {
                            $(powerdata).each(function (powerid, powername) {
                                var rightsontbody = "";
                                rightsontbody += '<tr>';
                                rightsontbody += '<th width="40%"><input type="checkbox" name="rightcheck" value="' + powername.PowerID + '" /></th>  ';
                                rightsontbody += '<th width="60%">' + powername.PowerName + '</th>';
                                rightsontbody += '</tr>';
                                $("#righttable tbody").append(rightsontbody);
                            })
                        }
                    })
                })
            }
        })
    })
</script>